﻿<UserControl x:Class="GEPL.StandardModulesLibrary.Views.Common.ConditionIfView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:p="clr-namespace:GEPL.StandardModulesLibrary.Properties"
             xmlns:converters="clr-namespace:GEPL.StandardModulesLibrary.Converters"
             xmlns:vm="clr-namespace:GEPL.StandardModulesLibrary.ViewModels.Common"
             mc:Ignorable="d"
             Height="200"
             Width="200"
             d:DataContext="{d:DesignInstance vm:ConditionIfViewModel}">
    <UserControl.Resources>
        <converters:NegBoolToVisibilityConverter x:Key="NegBoolToVisibilityConverter" />
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid Visibility="{Binding EndIf, Mode=OneWay, Converter={StaticResource NegBoolToVisibilityConverter}}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <StackPanel Grid.Column="0"
                        Grid.ColumnSpan="2"
                        Grid.Row="0"
                        Margin="10">
                <RadioButton Content="{x:Static p:Resources.Conditions_If}"
                             IsChecked="{Binding If, Mode=TwoWay}" />
                <RadioButton Content="{x:Static p:Resources.Conditions_IfElse}"
                             IsChecked="{Binding IfElse, Mode=TwoWay}" />
                <RadioButton Content="{x:Static p:Resources.Conditions_Else}"
                             IsChecked="{Binding Else, Mode=TwoWay}" />
            </StackPanel>
            <Label Grid.Column="0"
                   Grid.Row="1"
                   Content="{x:Static p:Resources.Miscs_Value}"
                   Visibility="{Binding Else, Converter={StaticResource NegBoolToVisibilityConverter}}" />
            <TextBox Grid.Column="1"
                     Grid.Row="1"
                     Text="{Binding Value1, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                     Visibility="{Binding Else, Converter={StaticResource NegBoolToVisibilityConverter}}" />
            <ComboBox Grid.Column="0"
                      Grid.Row="2"
                      ItemsSource="{Binding ConditionsList, Mode=OneWay}"
                      SelectedValue="{Binding SelectedCondition, Mode=TwoWay}"
                      DisplayMemberPath="Value"
                      SelectedValuePath="Key"
                      Visibility="{Binding Else, Converter={StaticResource NegBoolToVisibilityConverter}}" />
            <TextBox Grid.Column="1"
                     Grid.Row="2"
                     Text="{Binding Value2, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                     Visibility="{Binding Else, Converter={StaticResource NegBoolToVisibilityConverter}}" />
        </Grid>
        <CheckBox Grid.Row="1"
                  Content="{x:Static p:Resources.Conditions_Close}"
                  IsChecked="{Binding EndIf, Mode=TwoWay}" />
    </Grid>
</UserControl>